<template>
	<div class="appPushHistory detal-box">
		<a-card :bordered="false">
			<a-form ref="formRef" :model="queryParams" :rules="formRules" @finish="getList('search')" layout="vertical"
				class="form-box">
				<a-row :gutter="15">
					<a-col :span="5">
						<a-form-item label="" name="pushContent">
							<a-input v-model:value="queryParams.pushContent" placeholder="请输入搜索内容" allow-clear />
						</a-form-item>
					</a-col>
					<a-col :span="8">
						<a-form-item label="">
							<a-range-picker :show-time="{ format: 'HH:mm' }" valueFormat="YYYY-MM-DD HH:mm"
								format="YYYY-MM-DD HH:mm" :placeholder="['开始时间', '结束时间']" v-model:value="timeRange" />
						</a-form-item>
					</a-col>
					<a-col :span="4">
						<a-form-item>
							<a-button type="primary" class="bt1" html-type="submit" :loading="btnLoading">查询</a-button>
						</a-form-item>
					</a-col>
				</a-row>
			</a-form>
		</a-card>
		<a-card class="mt10" :bordered="false">
			<a-table class="mt10 mb5" :dataSource="dataSource" :columns="columns" :pagination="false">
				<template #action="{ record }">
					<a @click="goDetail(record)">查看</a>
				</template>
			</a-table>
			<a-pagination show-size-changer show-quick-jumper :show-total="(total) => `共 ${total} 条`"
				v-model:current="queryParams.current" v-model:pageSize="queryParams.size" :total="total"
				@change="pageNumberChange" />
		</a-card>
	</div>
</template>
<script setup name="appPushHistory">
import appInfoApi from '@/api/biz/appInfoApi'
import { useRouter,useRoute } from 'vue-router'
import tool from '@/utils/tool'
const router = useRouter()
const route = useRoute()
const appId = route.query.appId
const timeRange = ref([])
const queryParams = ref({
	current: 1,
	size: 10,
	appId:appId
})
let total = ref(0)
const columns = [
	{
		title: '变更描述',
		dataIndex: 'appInfo',
	},
	{
		title: '变更时间',
		dataIndex: 'updateTime',
	},
	{
		title: '操作',
		dataIndex: 'action',
		slots: { customRender: 'action' }
	}
]
const dataSource = ref([])
const getList = (v) => {
	if (v === 'search') {
		queryParams.value.current = 1
		queryParams.value.size = 10
	}
	appInfoApi.historyList(queryParams.value).then((res) => {
		dataSource.value = res.records
		total.value = res.total
	})
}
const pageNumberChange = (page, pageSize) => {
	queryParams.value.current = page
	queryParams.value.size = pageSize
	getList()
}
// const goDetail = (item) => {
// 	router.replace({
// 		name: 'appPushUserInfo', 
// 		state: {
// 			id: item.id,
// 			batchId: item.batchId
// 		}
// 	})
// }
//查看详情主表
const goDetail = (item) => {
	console.log(item,'item')
	let json = {...JSON.parse(item.publicContent)}
	json.appInfoPcPropertiesAddParam = JSON.parse(item.pcContent)
	json.appInfoAppPropertiesAddParam = JSON.parse(item.appContent)
	tool.data.set('detailInfo',json)
	router.push({
		path: '/biz/appinfo/detail',
		query: {
			id: item.id,
			type:'history',
		},
		params:{
			type:'history'
		}
	})
}
getList()
</script>
<style lang="less" scoped>
.appPushHistory {
	.tit {
		color: #282828;
		font-family: PingFang SC;
		font-size: 18px;
		font-weight: 600;
		line-height: 28px;
		letter-spacing: 0px;
		text-align: left;
	}

	.btnBottom {
		text-align: right;
	}

	.ant-form-item {
		margin-bottom: 15px;
	}

	.mb5 {
		margin-bottom: 15px;
	}

	.mt10 {
		margin-top: 10px;
	}

	.mr20 {
		margin-right: 10px;
	}
}
</style>
